/**
 * @name 使用组件的文件上传
 */
interface InterfaceFileObj {
  fileId: number | string;
  visible: boolean;
  [key: string]: any;
}

interface InterfacePermissionCode {
  // 下载权限码
  downloadPermissionCode?: string;
  // 删除权限码
  deletePermissionCode?: string;
  // 上传权限码
  upLoadingPermissionCode?: string;
  // 文件预览
  previewPermissionCode?: string;
}

export const useCommonFile = (permissionCode?: InterfacePermissionCode) => {
  /**
   * 附件上传
   */
  let fileObj = ref<InterfaceFileObj>({
    fileId: '',
    visible: true,
    ...permissionCode
  });

  /**
   * 设置文件上传id
   */
  const setFileId = (id: string | number) => {
    fileObj.value.fileId = id;
  };

  return {
    fileObj,
    setFileId
  };
};
